package com.rdc.qingkou.presenter;

import com.rdc.qingkou.base.BasePresenterImpl;
import com.rdc.qingkou.model.OtherHomepageModel;
import com.rdc.qingkou.model.imodel.IOtherHomepageModel;
import com.rdc.qingkou.presenter.ipresenter.IOtherHomepagePresenter;
import com.rdc.qingkou.ui.iview.IOtherHomepageView;
import com.rdc.qingkou.vo.CardVO;
import com.rdc.qingkou.vo.UserVO;

import java.util.List;


public class OtherHomepagePresenter extends BasePresenterImpl<IOtherHomepageView> implements IOtherHomepagePresenter {

    private IOtherHomepageModel model;

    public OtherHomepagePresenter() {
        model = new OtherHomepageModel(this);
    }

    @Override
    public void sendGetCardRequest(int useId, int currentPage) {
        model.getCards(useId, currentPage);
    }

    @Override
    public void getCardSuccess(List<CardVO> list) {
        if (isAttachView()) {
            getMvpView().updateCard(list);
        }
    }

    @Override
    public void getCardError(String message) {
        if (isAttachView()) {
            getMvpView().getCardError(message);
        }
    }

    @Override
    public void subscribe(int subscribeId, int userId) {
        model.Subscribe(subscribeId, userId);
    }

    @Override
    public void subscribeError(String message) {
        if (isAttachView()) {
            getMvpView().subscribeError(message);
        }
    }

    @Override
    public void subscribeSuccess(boolean status) {
        if (isAttachView()) {
            getMvpView().subscribeSuccess(status);
        }
    }

    @Override
    public void getUserInfo(int userId) {
        model.getUserInfo(userId);
    }

    @Override
    public void getUserInfoSuccess(UserVO userVO) {
        if (isAttachView()) {
            getMvpView().setUserInfo(userVO);
        }
    }

    @Override
    public void getUserInfoError(String message) {
        if (isAttachView()) {
            getMvpView().getUserInfoError(message);
        }
    }

    @Override
    public void getSubscribeStatus(int subscribeId, int userId) {
        model.getSubscribeStatus(subscribeId, userId);
    }

    @Override
    public void getSubscribeStatusSuccess(boolean status) {
        if (isAttachView()) {
            getMvpView().setSubscribeStatus(status);
        }
    }

    @Override
    public void getSubscribeStatusError(String message) {
        if (isAttachView()) {
            getMvpView().getSubscribeStatusError(message);
        }
    }

    @Override
    public void clearDisposable() {
        model.clearDisposable();
    }
}
